//
//  InpatientCell.m
//  掌上宏力
//
//  Created by admin on 2017/6/7.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "InpatientCell.h"
#import "InPatientModel.h"

@interface InpatientCell ()

@property (nonatomic,weak) UILabel  *nameLab;
@property (nonatomic,weak) UILabel *healthyLab;
@property (nonatomic,weak) UILabel *doctorLab;
@property (nonatomic,weak) UILabel *mainDocLab;

@end

static CGFloat lab_H = 30;
static CGFloat lef_W = 80;
static CGFloat lef_dis = 5;

@implementation InpatientCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UIView *view = [Factory createViewWithBackgroundColor:[UIColor whiteColor] frame:CGRectMake(LeftDis, 0, kScreenW-LeftDis*2, 130)];
        view.layer.cornerRadius = 5;
        [self.contentView addSubview:view];
        NSArray *titles = @[@"姓        名:",@"入院诊断:",@"主管医生:",@"主任医生:"];
        CGFloat text_W = kScreenW-lef_W-LeftDis*2-lef_dis*2;
        //姓名
        UILabel *nameL = [Factory createLabelWithTitle:titles[0] frame:CGRectMake(lef_dis, 5, lef_W, lab_H) fontSize:15];
        [view addSubview:nameL];
        UILabel *nameLab = [Factory createLabelWithFrame:CGRectMake(nameL.right, 5, text_W, lab_H) fontSize:15];
        [view addSubview:nameLab];
        self.nameLab = nameLab;
        //入院诊断
        UILabel *healthyL = [Factory createLabelWithTitle:titles[1] frame:CGRectMake(lef_dis, nameL.bottom, lef_W, lab_H) fontSize:15];
        [view addSubview:healthyL];
        UILabel *healthyLab = [Factory createLabelWithFrame:CGRectMake(healthyL.right, nameLab.bottom, text_W, lab_H) fontSize:15];
        [view addSubview:healthyLab];
        self.healthyLab = healthyLab;
        //主管医生
        UILabel *doctorL = [Factory createLabelWithTitle:titles[2] frame:CGRectMake(lef_dis, healthyL.bottom, lef_W, lab_H) fontSize:15];
        [view addSubview:doctorL];
        UILabel *doctorLab = [Factory createLabelWithFrame:CGRectMake(doctorL.right, healthyLab.bottom, text_W, lab_H) fontSize:15];
        [view addSubview:doctorLab];
        self.doctorLab = doctorLab;
        //主任医生
        UILabel *mainDocL = [Factory createLabelWithTitle:titles[3] frame:CGRectMake(lef_dis, doctorL.bottom, lef_W, lab_H) fontSize:15];
        [view addSubview:mainDocL];
        UILabel *mainDocLab = [Factory createLabelWithFrame:CGRectMake(mainDocL.right, doctorLab.bottom, text_W, lab_H) fontSize:15];
        [view addSubview:mainDocLab];
        self.mainDocLab = mainDocLab;
    }
    return self;
}
-(void)setInpatient:(InPatientModel *)inpatient{
    self.nameLab.text = inpatient.name;
    self.healthyLab.text = inpatient.healthy;
    self.doctorLab.text = inpatient.doctor;
    self.mainDocLab.text = inpatient.mainDoc;
}
+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId = @"cellId";
    InpatientCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[InpatientCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
